home *** CD-ROM | disk | FTP | other *** search
- #!/bin/csh
-
- # usage:
- # pdb-model file.pdb file.model
- #
- # create a *.model file for ribbons
- # script generates temporary files in the current directory!
-
- # temporary files, with current process appended "$$"
- set model = pdbmod.$$
- set awkfile = pdbcom.$$
- set awkout = pdbout.$$
-
- cat <<'EOF' > $awkfile
- BEGIN { xc=0.0; yc=0.0; zc=0.0; n=0; }
- $1=="ATOM" || $1=="HETATM" {
- x = 0.0 + substr($0,31,8);
- y = 0.0 + substr($0,39,8);
- z = 0.0 + substr($0,47,8);
- xc += x;
- yc += y;
- zc += z;
- n++;
- }
- END { if(n) { xc/=n; yc/=n; zc/=n; } \
- printf(" %.2f %.2f %.2f (~Center-of-Mass for %d atoms)\n",xc,yc,zc,n);}
- 'EOF'
-
- echo $1:r > $model
- awk -f $awkfile < $1 > $awkout
- paste $model $awkout > $2
-
- /bin/rm -f $model $awkfile $awkout
-